package com.vornitologist.ui;

import com.vaadin.addon.touchkit.ui.NavigationView;
import com.vaadin.addon.touchkit.ui.TouchKitWindow;
import com.vaadin.addon.touchkit.ui.VerticalComponentGroup;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.Label;

/**
 * A settings view for the applicaiton.
 * <p>
 * As the purpose of this application is to demo Vaadin TouchKit, we are also
 * using this as a landing page for users. Some settings don't actually do
 * anything, but just demonstrate TouchKit specific components.
 */
public class SettingsView extends NavigationView {

	@Override
	public void attach() {
		super.attach();
		buildView();
	}

	private void buildView() {

		CssLayout content = new CssLayout();
		content.setWidth("100%");

		VerticalComponentGroup componentGroup = new VerticalComponentGroup();
		componentGroup.setCaption("About HawaiiTocuh:");

		Label about = new Label(
				"<div style='color:#333;'><p>HawaiiTouch permite ver Tareas, Procesos"
						+ " y toda la informacion asociada a los mismos "
						+ "etc.."
						+ "<a href=\""
						+ getApplication().getURL()
						,
				Label.CONTENT_XHTML);

		componentGroup.addComponent(about);

		content.addComponent(componentGroup);

		componentGroup = new VerticalComponentGroup();
		componentGroup.setCaption("Settings");
		componentGroup
				.addComponent(new Label(
						"Alguna configuracion.."));
		
		Button button = new Button("Ir a modo offline");
		button.addListener(new Button.ClickListener() {
			public void buttonClick(ClickEvent event) {
				((TouchKitWindow) getWindow()).goOffline();
			}
		});
		componentGroup.addComponent(button);

		content.addComponent(componentGroup);

		setContent(content);

	}
}
